<template>
  <div id="app" v-bind:style="appDivStyle">
      <div class="context" ref="context">
           <div class="queryBox" ref="queryBox">
                <el-form :model="formQueryCondition"
                         ref="form" size="mini">
                    <!--查询条件-->
                    <!--资产编号-->
                  <el-row>
                    <el-col :span="5">
                    <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.code')"
                    :label-width="queryformLabelWidth">
                        <el-input v-model.trim="formQueryCondition.code.val" class="queryItemStyle" clearable
                                  :placeholder="$t('shellAssets.queryLabel.shellAssets.placeholderCode')"></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <!--资产名称-->
                    <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.name')"   :label-width="queryformLabelWidth">
                        <el-input v-model.trim="formQueryCondition.name.val" class="queryItemStyle" clearable
                                  :placeholder="$t('shellAssets.queryLabel.shellAssets.placeholderName')">
                        </el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <!--资产来源-->
                    <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.source')"  :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition.source.val" class="queryItemStyle">
                            <el-option :label="$t('shellAssets.label.all')" value=""></el-option>
                            <el-option :value="item.keyId" :key="item.keyId" :label="item.speAreaName" v-for="item in assetSourceData"></el-option>
                            <!-- <el-option :label="$t('shellAssets.label.shellAssetsSource1')" value="shellAssetsSource1"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsSource2')" value="shellAssetsSource2"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsSource3')" value="shellAssetsSource3"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsSource4')" value="shellAssetsSource4"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsSource5')" value="shellAssetsSource5"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsSource6')" value="shellAssetsSource6"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsSource7')" value="shellAssetsSource7"></el-option> -->
                        </el-select>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <!--资产类型-->
                    <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.type')"  :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition.type.val" class="queryItemStyle">
                            <el-option :label="$t('shellAssets.label.all')" value=""></el-option>
                            <el-option :value="item.valueCode" :key="item.valueCode" :label="item.valueText" v-for="item in assetTypeData"></el-option>
                            <!-- <el-option :label="$t('shellAssets.label.shellAssetsType1')" value="shellAssetsType1"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsType2')" value="shellAssetsType2"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsType3')" value="shellAssetsType3"></el-option>
                            <el-option :label="$t('shellAssets.label.shellAssetsType4')" value="shellAssetsType4"></el-option> -->
                        </el-select>
                    </el-form-item>
                    </el-col>
                  </el-row>
                    <!--资产状态-->
                    <!-- <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.status')"  :label-width="queryformLabelWidth">
                        <el-select v-model="formQueryCondition.status.val" class="queryItemStyle">
                            <el-option :value="item.valueCode" :key="item.valueCode" :label="item.valueText" v-for="item in approvalStatusData"></el-option>
                        </el-select>
                    </el-form-item> -->
                    <!--创建时间-->
                  <el-row>
                    <el-col :span="5">
                    <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.createTime')"  :label-width="queryformLabelWidth">
                        <el-date-picker v-model="formQueryCondition.createTimeStart.val" class="queryItemStyle"
                                        type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')">
                        </el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <el-form-item :label="$t('shellAssets.label.zhi')"  :label-width="queryformLabelWidth">
                        <el-date-picker v-model="formQueryCondition.createTimeEnd.val" class="queryItemStyle"
                                        type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">

                    <!--修改时间-->
                    <!-- <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.lastUpdateTime')"  :label-width="queryformLabelWidth">
                        <el-date-picker v-model="formQueryCondition.lastUpdateTimeStart.val" class="queryItemStyle"
                                        type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                    </el-form-item>
                    <el-form-item :label="$t('shellAssets.label.zhi')"  :label-width="queryformLabelWidth">
                        <el-date-picker v-model="formQueryCondition.lastUpdateTimeEnd.val" class="queryItemStyle"
                                       type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                    </el-form-item> -->

                    <!--授权到期时间-->
                    <el-form-item :label="$t('shellAssets.queryLabel.shellAssets.expireTime')"  :label-width="queryformLabelWidth">
                        <el-date-picker v-model="formQueryCondition.expireTimeStart.val" class="queryItemStyle"
                                        type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                    </el-form-item>
                    </el-col>
                    <el-col :span="5" :offset="1">
                    <el-form-item :label="$t('shellAssets.label.zhi')"  :label-width="queryformLabelWidth">
                        <el-date-picker v-model="formQueryCondition.expireTimeEnd.val" class="queryItemStyle"
                                         type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                    </el-form-item>
                    </el-col>
                  </el-row>


                    <!--列表上面的按钮-->
                <el-row>
                  <el-col :span="24">
                    <div style="text-align:right">
                        <!--新增-->
                        <!--重置-->
                        <el-form-item>
                            <el-button v-permission="{menuCode: menuCode, resourceCode: 'resetBtnText'}"
                             type="primary" @click="onReset('form')">{{ $t('shellAssets.btnText.resetBtnText') }}</el-button>
                        <!--查询-->
                            <el-button v-permission="{menuCode: menuCode, resourceCode: 'queryBtnText'}"
                             type="primary" @click="onQuery" icon="el-icon-search" :loading="loading">{{ $t('shellAssets.btnText.queryBtnText') }}</el-button>
                        </el-form-item>
                    </div>
                  </el-col>
                </el-row>
                </el-form>
            </div>
            <!--列表-->
            <div class="dataBox" ref="dataBox">

                <el-table v-if="isInit" ref="singleTable"
                            :data="tableData"
                            :height="tableHeight"
                            @sort-change="sortChange"
                            v-loading="loading" size="mini"
                            style="width: 100%;" stripe=stripe border=border>
                    <!--序号-->
                    <el-table-column type="index"  width="50" fixed="left"
                                        :label="$t('table.xh')" align="center">
                    </el-table-column>
                    <!--复选框-->
                    <!-- <el-table-column type="selection" width="35" fixed="left">
                    </el-table-column> -->
                    <!--操作-->
                    <el-table-column :label="$t('table.op')" fixed="left" min-width="220">
                        <template slot-scope="scope">
                            <!--资产详情-->
                            <el-button size="gv" icon="el-icon-tickets" :loading="loading"
                             v-permission="{menuCode: menuCode, resourceCode: 'detailsBtnText'}"
                             @click="clickDetails(scope.$index, scope.row,'detailsBtnText')"
                                        >{{ $t('shellAssets.btnText.detailsBtnText') }}</el-button>
                            <!--剧集-->
                            <el-button size="gv" icon="el-icon-tickets" :loading="loading"
                             v-permission="{menuCode: menuCode, resourceCode: 'subassetBtnText'}"
                             @click="selectAssetsInfo(scope.$index, scope.row)"
                                        >{{ $t('shellAssets.btnText.subAssetBtnText') }}</el-button>
                            <!--审核-->
                            <el-button size="gv" icon="el-icon-edit"
                                v-permission="{menuCode: menuCode, resourceCode: 'auditingBtnText'}"
                                :loading="loading" @click="onAudit(scope.$index, scope.row,'auditingBtnText')" :disabled="scope.row.assetStateByQuery != 'TheAuditFailed'"
                                    >{{ $t('shellAssets.btnText.auditingBtnText') }}</el-button>
                            <!--删除-->
                            <!-- <el-button size="gv" icon="el-icon-delete"
                                            type="danger" :loading="loading" @click="deleteRow(scope.$index, scope.row)"
                                            >{{ $t('btnText.deleteBtnText') }}</el-button> -->
                        </template>
                    </el-table-column>
                    <!--资产编号-->
                    <el-table-column prop="assetCode" min-width="130" fixed="left"
                                        :label="$t('shellAssets.table.shellAssets.code')" sortable="custom" sort-by="assetCode">
                    </el-table-column>
                    <!--资产名称-->
                    <el-table-column prop="assetName" min-width="180" fixed="left"
                                        :label="$t('shellAssets.table.shellAssets.name')" sortable="custom" sort-by="assetName">
                    </el-table-column>
                    <!--资产来源-->
                    <el-table-column prop="speAreaName" min-width="100"
                                        :label="$t('shellAssets.table.shellAssets.source')" sortable="custom" sort-by="speAreaName" >
                    </el-table-column>
                    <!--资产类型-->
                    <el-table-column prop="assetType" min-width="110"
                                        :label="$t('shellAssets.table.shellAssets.type')" sortable="custom" sort-by="assetType">
                    </el-table-column>
                    <!--状态-->
                    <el-table-column prop="assetState" min-width="110"
                                        :label="$t('shellAssets.table.shellAssets.status')" sortable="custom" sort-by="assetState">
                    </el-table-column>
                    <!--授权时间
                    <el-table-column prop="expireTime" min-width="120"
                                        :label="$t('shellAssets.table.shellAssets.expireTime')" sortable="custom" sort-by="expireTime">
                    </el-table-column>
                    -->
                    <!--版权结束时间-->
                    <el-table-column prop="copyrightEndDate" min-width="180"
                                        :label="$t('shellAssets.table.shellAssets.expireEndTime')" sortable="custom" sort-by="copyrightEndDate">
                    </el-table-column>
                    <!--创建时间-->
                    <el-table-column prop="createdDate" min-width="180"
                                        :label="$t('shellAssets.table.shellAssets.createTime')" sortable="custom" sort-by="createdDate">
                    </el-table-column>
                    <!--最后修改时间-->
                    <el-table-column :label="$t('shellAssets.table.lastUpdateTime')" min-width="180" sortable="custom" prop="lastUpdatedDate" sort-by="lastUpdatedDate">
                    </el-table-column>
                    <!--最后修改人-->
                    <el-table-column :label="$t('shellAssets.table.lastUpdatedBy')" min-width="180" sortable="custom" prop="modifier" sort-by="modifier">
                    </el-table-column>

                </el-table>


            </div>
        </div>
        <!--分页-->
        <div class="pageBox">
            <el-pagination @size-change="sizeChange"
                            @current-change="currentPageChange"
                            :current-page="pager.curPage"
                            :page-sizes="pager.sizes"
                            :page-size="pager.curSize"
                            :background="true"
                            layout="total, sizes, prev, pager, next, jumper" :total="pager.total">
            </el-pagination>
        </div>

        <!--编辑对话框-->
        <el-dialog :title="$t('label.dialogTitle')" :visible.sync="isShowEditForm" top="5vh" :close-on-click-modal="false">
            <el-form :model="editForm" ref="editForm" size="mini"
                     :label-position="editFormPosition" status-icon=status-icon :rules="editRules">

                <!--资产名称-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.name')" :label-width="editformLabelWidth" prop="name">
                    <el-input v-model.trim="editForm.name" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.name')"></el-input>
                </el-form-item>
                <!--资产类型-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.type')" :label-width="editformLabelWidth">
                    <el-select v-model="editForm.type">
                        <el-option :label="$t('shellAssets.label.shellAssetsType1')" value="shellAssetsType1"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsType2')" value="shellAssetsType2"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsType3')" value="shellAssetsType3"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsType4')" value="shellAssetsType4"></el-option>
                    </el-select>
                </el-form-item>
                <!--资产来源-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.source')" :label-width="editformLabelWidth">
                    <el-select v-model="editForm.source">
                        <el-option :label="$t('shellAssets.label.shellAssetsSource1')" value="shellAssetsSource1"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsSource2')" value="shellAssetsSource2"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsSource3')" value="shellAssetsSource3"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsSource4')" value="shellAssetsSource4"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsSource5')" value="shellAssetsSource5"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsSource6')" value="shellAssetsSource6"></el-option>
                        <el-option :label="$t('shellAssets.label.shellAssetsSource7')" value="shellAssetsSource7"></el-option>
                    </el-select>
                </el-form-item>
                <!--资产提供方信息-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.sourceInfo')" :label-width="editformLabelWidth" prop="sourceInfo">
                    <el-input v-model.trim="editForm.sourceInfo" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.sourceInfo')"></el-input>
                </el-form-item>
                <!--版权开始时间-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.expireTime')" :label-width="editformLabelWidth" prop="expireTime">
                    <el-date-picker v-model="editForm.expireTimeStart" type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                </el-form-item>
                <!--版权结束时间-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.expireEndTime')" :label-width="editformLabelWidth" prop="expireEndTime">
                    <el-date-picker v-model="editForm.expireTimeEnd" type="date" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                </el-form-item>
                <!--首字母-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.initials')" :label-width="editformLabelWidth" prop="initials">
                    <el-input v-model.trim="editForm.initials" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.initials')"></el-input>
                </el-form-item>
                <!--年份-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.years')" :label-width="editformLabelWidth" prop="years">
                    <el-date-picker v-model="editForm.years" type="year" :placeholder="$t('shellAssets.label.pleaseSelectTime')"></el-date-picker>
                </el-form-item>
                <!--地区-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.area')" :label-width="editformLabelWidth">
                    <el-select v-model="editForm.area">
                        <el-option :label="$t('shellAssets.label.area1')" value="area1"></el-option>
                        <el-option :label="$t('shellAssets.label.area2')" value="area2"></el-option>
                        <el-option :label="$t('shellAssets.label.area3')" value="area3"></el-option>
                        <el-option :label="$t('shellAssets.label.area4')" value="area4"></el-option>
                        <el-option :label="$t('shellAssets.label.area5')" value="area5"></el-option>
                    </el-select>
                </el-form-item>
                <!--语言-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.language')" :label-width="editformLabelWidth" prop="language">
                    <el-input v-model.trim="editForm.language" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.language')"></el-input>
                </el-form-item>
                <!--集数-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.episode')" :label-width="editformLabelWidth" prop="episode">
                    <el-input v-model.trim="editForm.episode" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.episode')"></el-input>
                </el-form-item>
                <!--导演-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.director')" :label-width="editformLabelWidth" prop="director">
                    <el-input v-model.trim="editForm.director" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.director')"></el-input>
                </el-form-item>
                <!--编辑-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.edit')" :label-width="editformLabelWidth" prop="edit">
                    <el-input v-model.trim="editForm.edit" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.edit')"></el-input>
                </el-form-item>
                <!--演员-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.actor')" :label-width="editformLabelWidth" prop="actor">
                    <el-input v-model.trim="editForm.actor" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.actor')"></el-input>
                </el-form-item>
                <!--播出状态-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.playStatus')" :label-width="editformLabelWidth">
                    <el-select v-model="editForm.playStatus">
                        <el-option :label="$t('shellAssets.label.playStatus1')" value="playStatus1"></el-option>
                        <el-option :label="$t('shellAssets.label.playStatus2')" value="playStatus2"></el-option>
                    </el-select>
                </el-form-item>
                <!--评分-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.score')" :label-width="editformLabelWidth" prop="score">
                    <el-input v-model.trim="editForm.score" maxlength="20"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.score')"></el-input>
                </el-form-item>
                <!--简介-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.introduction')" :label-width="editformLabelWidth" prop="introduction">
                    <el-input v-model.trim="editForm.introduction" maxlength="300"  type="textarea"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.introduction')"></el-input>
                </el-form-item>
                <!--剧情-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.plot')" :label-width="editformLabelWidth" prop="plot">
                    <el-input v-model.trim="editForm.plot" maxlength="300"  type="textarea"
                              :placeholder="$t('shellAssets.label.placeholder')+$t('shellAssets.editLabel.shellAssets.plot')"></el-input>
                </el-form-item>
                <!--海报-->
                <el-form-item :label="$t('shellAssets.editLabel.shellAssets.poster')" :label-width="editformLabelWidth" prop="poster">
                    <el-upload v-model.trim="editForm.poster" class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/"
                               :on-preview="handlePreview" :on-remove="handleRemove"
                               :file-list="fileList2" list-type="picture"> <el-button size="small" type="primary">点击上传</el-button>
                    <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <div slot="footer">
                <!--取消按钮-->
                <el-button size="mini" @click="isShowEditForm = false" :loading="loading">{{ $t('btnText.cancelBtnText') }}</el-button>
                <!--保存按钮-->
                <el-button size="mini" type="primary" @click="submitForm('editForm')" :loading="loading">{{ $t('btnText.saveBtnText') }}</el-button>
            </div>
        </el-dialog>

        <!--详情对话框-->
        <el-dialog :title="$t('label.dialogDetails')" :visible.sync="isShowDetails" top="5vh" width="60%" :close-on-click-modal="false">
            <el-tabs v-model="activeName" type="border-card">
            <el-tab-pane :label="$t('label.assetsInfo')" name="first">
                <assets-info :datas="dataForm"></assets-info>
            </el-tab-pane>

            </el-tabs>
        </el-dialog>

        <!--审核对话框-->
        <el-dialog :title="$t('assetsAudit.auditing')" :visible.sync="isShowReviewForm" top="5vh" width="60%" @close="refresh" :close-on-click-modal="false">
            <el-form :model="auditForm" ref="auditForm" size="mini"
                     :label-position="editFormPosition" status-icon=status-icon :rules="auditRules">
                <el-form-item :label="$t('assetsAudit.rejects')" :label-width="editformLabelWidth"  prop="rejects">
                    <el-input v-model.trim="auditForm.rejects" :disabled="true" type="textarea" :rows="2"  >></el-input>
                </el-form-item>
                <el-form-item :label="$t('assetsAudit.auditSuggestion')" :label-width="editformLabelWidth" prop="reviewDesc">
                    <el-input v-model.trim="auditForm.reviewDesc" type="textarea" :rows="2"  :placeholder="$t('label.pleaseInput')">></el-input>
                </el-form-item>
                <el-form-item  :label-width="editformLabelWidth" >
                    <el-button size="mini" type="primary"  @click="submitFormForPass(currentResCode)" :loading="loading">{{$t('assetsAudit.pass')}}</el-button>
                    <el-button size="mini" type="primary"  @click="submitFormForReject('auditForm',currentResCode)" :loading="loading">{{$t('assetsAudit.reject')}}</el-button>
                    <el-button size="mini" @click="isShowReviewForm = false" :loading="loading">{{ $t('btnText.cancelBtnText') }}</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>

  </div>


</template>

<script>

import comBaseVue from '../../baseViewModel';
import assetsInfo from  './ShellAssetsInfo';

export default {
  mixins: [comBaseVue],
  name:'ShellAssets',
  props: {
    menuCode: String,
  },
  data () {

    return {
        isShowActor:  false,
        isShowDetails:false,
        activeName: 'first',
        isShowReviewForm: false,
        isInit:false,
        tableHeight:100,
        queryformLabelWidth:"84px",
        assetTypeData:[],
        assetSourceData:[],
        approvalStatusData:[],
        appDivStyle:{
            height:this.$store.getters.appHeight,
        },
        modelName:"com.ispr.iptv.entity.media.AssetEntity",//操作的实体类
        modelName2:"com.ispr.iptv.entity.media.VAssetEntity",//操作的实体类F

        fileList2: [],
        //
        changeLogData:[],
        // 查询条件
        formQueryCondition: {
            code: {
                key: 'assetCode',
                op: 'LIKE', // 操作符
                val: '' // 查询的值
            },
            name: {
                key: 'assetName',
                op: 'LIKE',
                val: ''
            },
            source: {
                key: 'assetSource',
                op: '=',
                val: ''
            },
            type: {
                key: 'assetType',
                op: '=',
                val: ''
            },
            status: {
                key: 'assetState',
                op: '=',
                val: 'TheAuditFailed',
                group: 'status'
            },
            isTheauditfailed: {
                key: 'isTheauditfailed',
                op: '=',
                val: 'YES',
                group: 'status'
            },
            createTimeStart: {
                key: 'createdDate',
                group: 'createTimeStart',
                op: '>=',
                val: ''
            },
            createTimeEnd: {
                key: 'createdDate',
                group: 'createTimeEnd',
                op: '<=',
                val: ''
            },
            // lastUpdateTimeStart: {
            //     key: 'lastUpdatedDate',
            //     group: 'lastUpdateTimeStart',
            //     op: '>=',
            //     val: ''
            // },
            // lastUpdateTimeEnd: {
            //     key: 'lastUpdatedDate',
            //     group: 'lastUpdateTimeEnd',
            //     op: '<=',
            //     val: ''
            // },
            expireTimeStart: {
                key: 'copyrightEndDate',
                group: 'expireTimeStart',
                op: '>=',
                val: ''
            },
            expireTimeEnd: {
                key: 'copyrightEndDate',
                group: 'expireTimeEnd',
                op: '<=',
                val: ''
            },
            isEnable: {
                key: 'isEnable', // 操作符
                op: '=', // 操作符
                val: 'Available' // 查询的值
            },
        },

        // 编辑面板绑定的对象
        editForm: {
            keyId: 0,
            version: 0,
            name: "",
            type: "",
            source: "",
            userStatus: "",
            boxType: "",
            operator: "",

            tname: "",
            type: "",
            source: "",
            sourceInfo: "",
            expireTimeStart: "",
            expireTimeEnd: "",
            classification: "",
            initials: "",
            years: "",
            area: "",
            language: "",
            episode: "",
            director: "",
            edit: "",
            actor: "",
            playStatus: "",
            boxOffice: "",
            score: "",
            introduction: "",
            plot: "",
            poster: "",
            auditSuggestion: "",
        },
        // 编辑面板的验证规则
        editRules: {
            name: [{ required: true, message: this.$i18n.t('shellAssets.label.placeholder')+this.$i18n.t('shellAssets.editLabel.shellAssets.name'), trigger: 'blur' }],
            auditSuggestion: [{ required: true, message: this.$i18n.t('assetsAudit.rules.auditSuggestion'), trigger: 'blur' }],
        },
        dataForm: {
            keyId: 0,
            version: 0,
            assetCode: "",
            assetName: "",
            assetSource: "",
            assetType: "",
            providerInfo:"",
            AssetStatus:"",
            createTime:"",
            updateTime:"",
            tag:"",
            sort:"",
            copyRightTimeS:"",
            copyRightTimeE:"",
            copyRightSource:"",
            copyRightRemark:"",
            cnName:"",
            firstChar:"",
            year:"",
            area:"",
            language:"",
            itemNum:"",
            contentSort:"",
            director:"",
            adaptor:"",
        },
        // 审核面板绑定的对象
        auditForm: {
            keyId: "",
            version: 0,
            assetVersion: "",
            reviewDataId: "",
            reviewDataType: "",
            isEnable: "",

            approvalStatus: "",
            reviewDesc: "",
            rejects:"",
        },
        auditRules: {
            reviewDesc: [{ required: true, message: this.$i18n.t('assetsAudit.rules.auditSuggestion'), trigger: 'blur' }],
        },
    }
  },
  methods:{
     // 查询按钮
    onQuery: function(rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        if(this.formQueryCondition.createTimeStart.val!=null
        && this.formQueryCondition.createTimeStart.val!=""){
            this.formQueryCondition.createTimeStart.val=this.formatDate(this.formQueryCondition.createTimeStart.val);
        }
        if(this.formQueryCondition.createTimeEnd.val!=null
        && this.formQueryCondition.createTimeEnd.val!=""){
            this.formQueryCondition.createTimeEnd.val=this.formatDate(this.formQueryCondition.createTimeEnd.val);
        }
        if(this.formQueryCondition.expireTimeStart.val!=null
        && this.formQueryCondition.expireTimeStart.val!=""){
            this.formQueryCondition.expireTimeStart.val=this.formatDate(this.formQueryCondition.expireTimeStart.val);
        }
        if(this.formQueryCondition.expireTimeEnd.val!=null
        && this.formQueryCondition.expireTimeEnd.val!=""){
            this.formQueryCondition.expireTimeEnd.val=this.formatDate(this.formQueryCondition.expireTimeEnd.val);
        }
        this.pager.curPage = 1;
        this.queryTable();
    },
    // 查询网格数据
    queryTable: function() {
        this.loading = true;
        this.queryModel(this.modelName2,"Query",this.formQueryCondition,this.pager,this.sort,this.setTableData)
    },

     // 查询网格数据
    // queryTable: function() {
    //     this.loading = true;
    //     this.auditConfirmQuery("/api/mediaAudit/confirm",this.modelName,"Query",this.formQueryCondition,this.pager,this.sort,this.setTableData);
    // },

    // 新增
    onNew: function() {
        this.isShowEditForm = true;
        if (this.$refs['editForm']) {
            this.$refs['editForm'].resetFields();
        }
        this.editForm.keyId = "";
        this.editForm.version = "";
        this.editForm.name = "";//"资产名称",
        this.editForm.type = "shellAssetsType1";//"资产类型",
        this.editForm.source = "shellAssetsSource1";//"资产来源",
        this.editForm.sourceInfo = "";//"资产提供方信息",
        this.editForm.expireTimeStart = "";//"版权开始时间",
        this.editForm.expireTimeEnd = "";//"版权结束时间",
        this.editForm.classification = "";//"资产类型",
        this.editForm.initials = "";//"首字母",
        this.editForm.years = "2018";//"年份",
        this.editForm.area = "area1";//"地区",
        this.editForm.language = "";//"语言",
        this.editForm.episode = "";//"集数",
        this.editForm.director = "";//"导演",
        this.editForm.edit = "";//"编辑",
        this.editForm.actor = "";//"演员",
        this.editForm.playStatus = "playStatus1";//"播出状态",
        this.editForm.boxOffice = "";//"票房",
        this.editForm.score = "";//"评分",
        this.editForm.introduction = "";//"简介",
        this.editForm.plot = "";//"剧情",
        this.editForm.poster = "";//"海报",
        this.curCommand = "SaveNew";
        this.canEditCode = false;
    },

     // 重置
    onReset:function(){
        if (this.$refs['form']) {
            this.$refs['form'].resetFields();
        }
        this.formQueryCondition.code.val = "";
        this.formQueryCondition.name.val = "";
        this.formQueryCondition.source.val = "";
        this.formQueryCondition.type.val = "";
        // this.formQueryCondition.status.val = "TheAuditFailed";
        this.formQueryCondition.createTimeStart.val = "";
        this.formQueryCondition.createTimeEnd.val = "";
        // this.formQueryCondition.lastUpdateTimeStart.val = "";
        // this.formQueryCondition.lastUpdateTimeEnd.val = "";
        this.formQueryCondition.expireTimeStart.val = "";
        this.formQueryCondition.expireTimeEnd.val = "";
    },

    // 授权按钮单击事件
    editMenu: function(index, row) {

    },


    // 编辑按钮回调事件
    editCallback: function(isSuccess,json) {
        if(isSuccess){
            this.curCommand = "UpdateProc";
            this.isShowEditForm = true;
            if (this.$refs['editForm']) {
                this.$refs['editForm'].resetFields();
            }
            this.editForm.keyId = json.keyId;
            this.editForm.version = json.version;
            this.editForm.name = json.name;//"资产名称",
            this.editForm.type = json.type;//"资产类型",
            this.editForm.source = json.source;//"资产来源",
            this.editForm.sourceInfo = json.sourceInfo;//"资产提供方信息",
            this.editForm.expireTimeStart = json.expireTimeStart;//"版权开始时间",
            this.editForm.expireTimeEnd = json.expireTimeEnd;//"版权结束时间",
            this.editForm.classification = json.classification;//"资产类型",
            this.editForm.initials = json.initials;//"首字母",
            this.editForm.years = json.years;//"年份",
            this.editForm.area = json.area;//"地区",
            this.editForm.language = json.language;//"语言",
            this.editForm.episode = json.episode;//"集数",
            this.editForm.director = json.director;//"导演",
            this.editForm.edit = json.edit;//"编辑",
            this.editForm.actor = json.actor;//"演员",
            this.editForm.playStatus = json.playStatus;//"播出状态",
            this.editForm.boxOffice = json.boxOffice;//"票房",
            this.editForm.score = json.score;//"评分",
            this.editForm.introduction = json.introduction;//"简介",
            this.editForm.plot = json.plot;//"剧情",
            this.editForm.poster = json.poster;//"海报",
            this.canEditCode = true;

        }
        else{
            this.$message({
                message: json.msg,
                type: 'warning'
                });
        }
    },

    handleRemove(file, fileList) {
        console.log(file, fileList);
      },
    handlePreview(file) {
        console.log(file);
    },

    // 详情按钮单击事件
    clickDetails: function(index, row,rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
       this.queryModelByKeyID(this.modelName,row.keyId,"Query",this.showDetails);

    },
    // 详情按钮回调事件
    showDetails: function(isSuccess,json) {
       if(isSuccess){
            this.isShowDetails = true;
            this.dataForm=json;
            if(json.assetYear!=null && json.assetYear!="" && json.assetYear!="NaN"){
                this.dataForm.assetYear=json.assetYear;
            }else{
                this.dataForm.assetYear="";
            }
            var actor = "";
            var edit ="";
            var director = "";
            json.assetAndActorList.forEach(element =>{
                    var A = "";
                    if(element.profession == "导演"){
                        //element.profession == "director"
                        A = element.actorName;
                        if(director == ""){
                            director = A;
                        }else{
                            director = director+","+ A;
                        }
                    }else if(element.profession == "编剧"){
                        //element.profession == "screenwriter"
                        A = element.actorName;
                        if(edit == ""){
                            edit = A;
                        }else{
                            edit = edit+","+ A;
                        }
                    }else if(element.profession == "演员"){
                        //element.profession == "actor"
                        A = element.actorName;
                        if(actor == ""){
                            actor = A;
                        }else{
                            actor = actor+","+ A;
                        }
                    }
                })
            this.dataForm.director = director;//"导演",
            this.dataForm.adaptor = edit;//"编剧",
            this.dataForm.actor = actor;//"演员",

            this.dataForm.tagNameAll = "";
            let temp = "";
            json.assetAndTagList.forEach(element =>{
                if(temp==""){
                    temp = element.tagName;
                }else{
                    temp = element.tagName + "," + temp;
                }
            });
            this.dataForm.tagNameAll = temp;
        }else{
            this.$message({
                message: json.msg,
                type: 'warning'
                });
        }
    },
    handleClick(tab, event) {
        console.log(tab, event);
    },


    /**跳转到剧集 */
    selectAssetsInfo: function(index, row) {
        this.$parent.setCurrentComponent("TurnDown",{curRootAssets:{"assetId":row.keyId},isNeedGoBack:true,menuCode:this.menuCode });
        // this.queryModel("com.ispr.iptv.entity.media.SubAssetEntity","Query",{
        //      code: {key: 'assetId',op: '=',val: row.keyId}
        // },this.pager,this.sort,this.setTableDatas);
        // this.queryModel("Media.Audit.AssetIssuance","Query",{assetName: {val: row.assetName}},this.pager,this.sort,this.setTableDatas)
        //this.$parent.setCurrentComponent("TurnDown",{curRootAssets:row,isNeedGoBack:true });
    },


    setTableDatas: function(isSuccess,json) {
                // if (isSuccess) {
                //     this.tableDatas = [];
                //     for (var i = 0; i < json.list.length; i++) {
                //         this.tableDatas.push(json.list[i]);
                //     }
                // this.$parent.setCurrentComponent("TurnDown",{curRootAssets:this.tableDatas,isNeedGoBack:true,menuCode:this.menuCode });
                // }
        },
    /**查看演员信息 */
    selectActorInfo: function(index, row) {
        this.$parent.setCurrentComponent("Actor",{curRootAssets:row,isNeedGoBack:true });
            // this.$router.push({
            //     path: 'Actor',
            //     name: 'Actor',
            //     params: {
            //     code: row.code,
            //     name: row.name,
            // } });//跳转到该路由
    },
    editMenu:function(){
      this.$message({
                message: this.$i18n.t("操作成功"),
                type: 'success'
                });
    },
    editMenuTwo:function(){
      this.$message({
                message: this.$i18n.t("操作成功"),
                type: 'success'
                });
    },
    // 审核事件
    onAudit: function(index, row, rescode){
        this.currentResCode = (rescode && rescode!=='') ? rescode : '';
         //查询上次审核记录
        this.queryModel("com.ispr.iptv.entity.audit.ReviewHisEntity","Query",{
                reviewDataId: {key: 'reviewDataId',op: '=',val: row.keyId},
                version: {key: 'version',op: '=',val: "0"}
            },this.pager,this.sort,this.reviewCallback);
        this.auditForm.rejects = "";
        this.auditForm.reviewDesc = "";
        this.auditForm.reviewDataId= row.keyId;
        this.auditForm.assetVersion = row.version;
        this.auditForm.reviewDataType= "ASSET";
        this.auditForm.isEnable= "Available";
        this.isShowReviewForm = true;
    },
     //查询上次审核记录回调函数
    reviewCallback: function(isSuccess,json) {
        if(isSuccess){
            this.auditForm.rejects = json.list[0].reviewDesc;
        }
        else{
            this.$message({
                message: json.msg,
                type: 'warning'
                });
        }
    },

    submitFormForPass: function (rescode){
            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        this.auditForm.approvalStatus= "ExaminationPassed",
        this.loading = true;
        this.procCommand("MediaAuditProc",
        "com.ispr.iptv.entity.media.AssetEntity",
        "Default",
        {
            "keyId":this.auditForm.reviewDataId,
            "version":this.auditForm.assetVersion,
            "assetState":this.auditForm.approvalStatus,
            "reviewHisEntity":this.auditForm
        },
        null,
        this.commonCallback);
    },

    submitFormForReject: function (formName, rescode){
            this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        var _this = this;
        //两次审核不通过状态改为废弃
        this.auditForm.approvalStatus= "Discard",
        this.$refs[formName].validate(function (valid) {
            if (valid) {
                _this.loading = true;
                _this.procCommand("MediaAuditProc",
                "com.ispr.iptv.entity.media.AssetEntity",
                "Default",
                {
                    "keyId":_this.auditForm.reviewDataId,
                    "version":_this.auditForm.assetVersion,
                    "assetState":_this.auditForm.approvalStatus,
                    "reviewHisEntity":_this.auditForm
                },
                null,
                _this.commonCallback);
            } else {
                return false;
            }
        });
    },

    commonCallback: function (isSuccess,json) {
        this.loading = false;
        this.isShowReviewForm = false;
        if(isSuccess){
            this.$message({
                message: this.$i18n.t("message.successTip"),//resource.message.successTip,
                type: 'success'
            });
            this.queryTable();
        }
        else
        {
            this.$message({
                            message: json.msg,
                            type: 'warning'
                            });
        }
    },
     //资产类型下拉列表数据
    findAssetType: function(){
        this.findByTypeCode("10005",this.setAssetTypeCallback);
    },

    setAssetTypeCallback: function(isSuccess,json){
        try{
            if (isSuccess) {
                for (var i = 0; i < json.data.length; i++) {
                    this.assetTypeData.push(json.data[i]);
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },

    //资产来源下拉列表数据
    findAssetSource: function(){
      var queryRequest = {
        className: "com.ispr.iptv.entity.sys.SpeArea",//修改为被查询的实体地址
        opKey: "Query",//后台编写相应的接口实现方法，主要负责转化类型
        params: [{key: 'isEnable',op: '=',val: 'Available'}],
        userInfo: this.getUserInfo()
      };
      var _this = this;
      this.axios.post('/api/query', queryRequest, {headers: this.headersObj})
      .then(function(res) {
      // alert(JSON.stringify(res));
      // alert(res.data.code);
        if (res.data.code == "SUCCESS") {
          _this.assetSourceData = [];
          for (var i = 0; i < res.data.data.length; i++) {
          _this.assetSourceData.push(res.data.data[i]);
          }
        } else {
        // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
        }
      })
      .catch(function(error) {
      console.log(error);
      // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
      });
    },


    //审核状态下拉列表数据
    findApprovalStatus: function(){
        this.findByTypeCode("10007",this.setApprovalCallback);
    },

    setApprovalCallback: function(isSuccess,json){
        try{
            if (isSuccess) {
                for (var i = 0; i < json.data.length; i++) {
                    if(json.data[i].valueCode=="TheAuditFailed"||json.data[i].valueCode=="ExaminationPassed"){
                        this.approvalStatusData.push(json.data[i]);
                    }
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },
    refresh: function(){
        if (this.$refs['auditForm']) {
            this.$refs['auditForm'].resetFields();
        }
    },
    initTable:function(){
        //alert("setTimeout");
        this.tableHeight = this.$refs.context.offsetHeight - this.$refs.queryBox.offsetHeight;
        this.isInit = true;
    },
    enterDown(){
      var g = this
      if(g.isShowEditForm){
        g.submitForm('editForm')
      }if(g.isShowReviewForm){
        g.submitFormForPass(g.currentResCode)
      }else if(g.isShowDetails){
        // 详情
        g.isShowDetails = false
      }else if(!g.loading){
        g.onQuery()
      }
    }

  },
  mounted: function mounted() {
        // this.formQueryCondition.status.val = "TheAuditFailed";
        this.findAssetType();
        this.findAssetSource();
        this.findApprovalStatus();
        this.onQuery();
        window.setTimeout(this.initTable,100);
  },
  components: {
    "assets-info": assetsInfo
  },
  activated: function(){
      this.onQuery();
  },
}


</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
